package cn.jdy.plugins.web;




import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.jdy.common.ctrl.BaseCtrl;
import cn.jdy.framework.log.BaseLog;
import cn.jdy.framework.util.DateUtil;
import cn.jdy.framework.util.IpUtil;
import cn.jdy.plugins.entity.AccessDetails;
import cn.jdy.plugins.service.AccessDetailsService;



/**
 * @title 保存访问记录
 * @author jga
 * @since 1-18-2017
 */

@Controller
@RequestMapping("/accessDetails")
public class AccessDetailsCtrl extends BaseCtrl{
	@Autowired
	private AccessDetailsService accessDetailsService;


	/**
	 * 保存访问记录
	 * @param news
	 * @return
	 */
	@RequestMapping("/saveA")
	@ResponseBody
	public Map<String, Object> saveA(AccessDetails ad) {
		
		Map<String, Object> jsonMap = new HashMap<String, Object>();
				try {
					String ip =IpUtil.getIp(request);// 访问者IP
					ad.setIp(ip);
					ad.setCreateTime(DateUtil.getCurrentDate(DateUtil._DEFAULT2));
					accessDetailsService.saveOrUpdate(ad);
				} catch(Exception e) {
					BaseLog.e(getClass(), "保存异常！", e);
				}
				return jsonMap;
	}
	
	
}
